<style>
    .footer.footer-home {display: none;}
    .shop-apply ul li select{width: 75%;border:none;float:left;}
</style>
<div class="header">
    <a href="index.php?act=member" class="return iconfont icon-shangyiye"></a>
    <div class="header-title">申请开店</div>
</div>
<div style="height:4rem;" class="ddd"></div>
<form id="applyForm" action="" method="post" enctype="multipart/form-data">
    <input type="hidden" name="form_submit" value="ok">
    <div class="shop-apply">
        <ul>
            <li>
                <label>姓名*</label>
                <input type="text" name="username" placeholder="如：张三" />
            </li>
            <li>
                <label>店铺名称*</label>
                <input type="text" name="shopname" placeholder="如：旅帮" />
            </li>
            <li>
                <label>手机号*</label>
                <input type="text" name="phone" value="<?php echo $output['member']['mobile']; ?>" readOnly="true" placeholder="如：13800000000" />
            </li>
            <li>
                <label>所在省份*</label>
                <select name="province_id" id="store_areaId_01" >
                    <option value="">请选择</option>
                    <?php if (is_array($output['provinces'])): ?>
                        <?php foreach($output['provinces'] as $key=> $value):?>
                            <option value="<?php echo $value['area_id'] ?>"><?php echo $value['name'] ?></option>
                            <?php endforeach; ?>
                    <?php endif; ?>
                </select>
            </li>
            <li>
                <label>所在城市*</label>
                <select name="city_id" id="store_areaId_02">
                </select>
            </li>
            <li>
                <label>所在地区*</label>
                <select name="area_id" id="store_areaId_03">
                </select>
            </li>
            <li>
                <label>详细地址*</label>
                <input type="text" name="addr" placeholder="如：xx街道xx号" />
            </li>
            <li class="block">
                <label>选择类型*</label>
                <div class="type-select">
                    <?php foreach ($output['cates'] as $cate): ?>
                    <div class="radio-box">
                        <input id="select<?php echo $cate['tc_id']; ?>" type="radio" name="type" value="<?php echo $cate['tc_id']; ?>"  />
                        <label for="select<?php echo $cate['tc_id']; ?>"></label>
                        <?php echo $cate['tc_name']; ?>
                    </div>
                    <?php endforeach; ?>
                </div>
            </li>
            <li class="block">
                <label>营业执照*</label>
                <div class="upload">
                    <div class="upload-file">
                        <input type="file" name="lic" class="upload-input"  accept="image/*" />
                    </div>
                </div>
                <p>照片清晰无遮挡物</p>
            </li>
            <li class="block">
                <label>经营者身份证照正面*</label>
                <div class="upload">
                    <div class="upload-file">
                        <input type="file" name="idcard" class="upload-input"  accept="image/*" />
                    </div>
                </div>
                <p>上传营业执照里经营者的身份证照片正面</p>
            </li>
            <li class="block">
                <label>经营者身份证照反面*</label>
                <div class="upload">
                    <div class="upload-file">
                        <input type="file" name="idcardb" class="upload-input"  accept="image/*" />
                    </div>
                </div>
                <p>上传营业执照里经营者的身份证照片反面</p>
            </li>
            <li class="block">
                <label>店铺的封面图*</label>
                <div class="upload">
                    <div class="upload-file">
                        <input type="file" name="mc_cover_img" class="upload-input"  accept="image/*" />
                    </div>
                </div>
                <p>上传您的店铺的封面</p>
            </li>
            <li class="border0 center" id="check">
                <div class="chek-box">
                    <div class="checkbox">
                        <input type="checkbox" id="che1" style="display: none;" />
                        <label for="iconfont"></label>
                    </div>
                    阅读并接受<samp id="xieyi" style="color: #d53131;">《开店协议》</samp>
                </div>
            </li>
            <li  class="border0">
                <input type="submit" id="sub-btn" value="提交" disabled style="background-color: #ccc;border-radius: 0.5rem;" class="btn-green" />
            </li>
        </ul>
    </div>
</form>
<div class="agree-content" style="display:none;position: absolute;left: 0;top: 0;height: 100%;width: 100%;background-color:#eaeaea;box-sizing: border-box;">
    <h1>用户协议</h1>
    <div class="agree-detail">
     <?php echo htmlspecialchars_decode($output['lic']); ?>
    </div>
    <div style="height: 10px;"></div>
    <input type="button" value="返回" onclick="closeRead();" class="btn-green" />
    <div style="height: 15px;"></div>
</div>

<script>
$('#sub-btn').click(function (e) {

    e.preventDefault();
    var form = $('#applyForm');
    if (form.find('input[name="username"]').val() == '') {
        popAlert('姓名不能为空');
        return;
    } else if (form.find('input[name="shopname"]').val() == '') {
        popAlert('店铺名称不能为空');
        return;
    } else if (!/^1\d{10}$/.test(form.find('input[name="phone"]').val())) {
        popAlert('手机号不正确');
        return;
    } else if (form.find('input[name="type"]:checked').length == 0) {
        popAlert('请选择类型');
        return;
    } else if(form.find('select[name="province_id"]').val() == ''){
        popAlert('请所在省份');
        return;
    } else if(form.find('select[name="city_id"]').val() == ''){
        popAlert('请所在城市');
        return;
    }else if(form.find('select[name="area_id"]').val() == ''){
        popAlert('请所在地区');
        return;
    }else if(form.find('input[name="addr"]').val() == ''){
        popAlert('详细地址不能为空');
        return;
    }else if (form.find('input[name="lic"]').val() == '') {
        popAlert('营业执照照片不能为空');
        return;
    } else if (form.find('input[name="idcard"]').val() == '') {
        popAlert('身份证正面照片不能为空');
        return;
    } else if (form.find('input[name="idcardb"]').val() == '') {
        popAlert('身份证反面照片不能为空');
        return;
    } else if (!$('#che1').is(':checked')) {
        popAlert('请先同意开店协议');
        return;
    } else {
        $.post('index.php?act=member&op=_check_merchant',{
            name:form.find('input[name="shopname"]').val(),
            mobile:form.find('input[name="phone"]').val(),
        },function(data){
            if(data.errcode==4001){
                popAlert(data._msg);
                return false;
            }else{
                form.submit();
            }
        },'json');
       // form.submit();
    }
});

//关闭协议
function closeRead() {
    <?php if($_GET['model']!='app'):?>
    $(".header").show();
    <?php endif; ?>
    $('.agree-content').fadeOut();
}
//打开协议
$('#xieyi').click(function (e) {
    $(".header").hide();
    e.stopPropagation();
    $('.agree-content').fadeIn();
});
//同意协议
$('#check').click(function () {
    var c = $('#che1');
    var i = c.is(':checked');
    c.prop('checked', !i);
    if (i) {
        $('#sub-btn').css('background-color', '#ccc').attr('disabled', 'disabled');
    } else {
        $('#sub-btn').css('background-color', '#129aee').removeAttr('disabled');
    }
});
    //选择省份
    $("#store_areaId_01").change(function(){
        var _areaID = $(this).val();
        _this = $("#store_areaId_01");
        if(_areaID){
            $.getJSON("./index.php?act=member&op=getAreaChild&parent_id=" + _areaID, function(data){
                $obj = $("#store_areaId_02");
                $obj.empty();
                $("#store_areaId_03").empty();
                $obj.append('<option value="">请选择城市</option>');
                $obj.nextAll("select").empty();
                $obj.nextAll("select").append('<option value="">区/县</option>');
                $.each(data, function(i,item){
                    $obj.append('<option value="'+item.area_id+'">'+item.name+'</option>');
                });
            });
        }else{
            _this.nextAll("select").empty();
            _this.next("select").append('<option value="">请选择城市</option>');
            _this.next("select").next('select').next('select').append('<option value="">请选择区县</option>');
        }
    });
//选择城市
$("#store_areaId_02").change(function(){
    var _areaID = $(this).val();
    _this = $("#store_areaId_2");
    if(_areaID){
        $.getJSON("index.php?act=member&op=getAreaChild&parent_id=" + _areaID, function(data){
            $obj = $("#store_areaId_03");
            $obj.empty();
            $obj.append('<option value="">请选择区县</option>');
            $.each(data, function(i,item){
                $obj.append('<option value="'+item.area_id+'">'+item.name+'</option>');
            });
        });
    }else{
        _this.nextAll("select").empty();
        _this.next("select").append('<option value="">请选择区县</option>');
    }
});
</script>